package com.info.zhiduoduo.repository.mapper.maker;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.maker.MakerZddprojectBidDto;
import com.info.zhiduoduo.repository.entity.maker.MakerZddProjectBid;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MakerZddProjectBidMapper extends BaseMapper<MakerZddProjectBid> {

	@Select(" select * from zdd_maker_zdd_project_bid where project_id = #{projectid} and userid = #{userid}")
	MakerZddProjectBid getByProjectIdUserid(Integer projectid, int userid);

	@Update(" update zdd_maker_zdd_project_bid set state = 4 where project_id = #{projectid} and userid != #{userid} and state = 1")
	int failOthers(int projectid, int userid);

	@Select(" select mzpb.*,ma.realname,ms.username,ms.intro from zdd_maker_zdd_project_bid mzpb " +
			" join zdd_maker_account ma on ma.userid = mzpb.userid " +
			" join zdd_maker_studio ms on ms.userid = mzpb.userid " +
			" where project_id = #{projectid}")
	List<MakerZddprojectBidDto> listByProjectid(Integer projectid);

	@Select(" select 1 from zdd_maker_zdd_project_bid where project_id = #{projectid} and userid = #{userid}")
	Integer isMakerBid(@Param("projectid") int projectid, @Param("userid") int userid);
}
